package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsCollect;
import com.qf.service.DtsCollectService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Zwnan
 */
@RestController
@RequestMapping("/admin/collect")
@CrossOrigin
public class CollectController {
    @Autowired
    private DtsCollectService dtsCollectService;

    @GetMapping("/list")
    public Object collectList(@RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "20") Integer limit
            ,@RequestParam(defaultValue = "add_time") String sort
            ,@RequestParam(defaultValue = "desc") String order){
        IPage<DtsCollect> iPage = dtsCollectService.selectPage(page,limit,sort,order);
        long total = iPage.getTotal();
        List<DtsCollect> records = iPage.getRecords();


        Map map = new HashMap();
        map.put("total", total);
        map.put("items", records);


        return ResponseUtil.ok(map);
    }

}
